<?php

use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

class CreateXyAuthMenuTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('xy_auth_menu', function (Blueprint $table) {
            $table->integer('id', true)->unique('id')->comment('ID');
            $table->string('namespace', 32)->default('uiadmin')->comment('根命名空间');
            $table->string('module', 32)->default('')->comment('所属模块');
            $table->string('title', 32)->default('')->comment('名称');
            $table->string('icon', 32)->default('')->comment('图标');
            $table->string('path', 32)->default('')->comment('路由路径');
            $table->string('pmenu', 32)->default('')->comment('父菜单');
            $table->integer('sortnum')->default(0)->comment('排序');
            $table->string('menu_layer', 32)->default('')->comment('分层标记');
            $table->integer('menu_type')->default(0)->comment('菜单类型1导航2按钮3仅接口');
            $table->string('route_type', 32)->default('')->comment('路由类型');
            $table->string('api_prefix', 15)->default('')->comment('接口前缀, 一般为：v1');
            $table->string('api_suffix', 32)->default('')->comment('接口路由参数后缀');
            $table->string('api_params', 32)->default('')->comment('接口Query参数');
            $table->string('out_url')->default('')->comment('外链地址或者远程组件地址');
            $table->boolean('is_dev')->default(false)->comment('是否开发者模式才显示');
            $table->dateTime('create_time')->nullable()->comment('创建时间');
            $table->dateTime('update_time')->nullable()->comment('更新时间');
            $table->boolean('status')->default(false)->comment('删除状态，0已禁用1正常');
            $table->string('tip')->default('')->comment('Tip');
            $table->string('api_method', 32)->default('')->comment('接口请求方法');
            $table->boolean('is_hide')->default(false)->comment('是否隐藏菜单');
            $table->text('doc')->nullable()->comment('接口文档');
            $table->string('api_ext', 32)->default('')->comment('接口虚拟后缀');
            $table->boolean('delete_time')->default(false)->comment('删除时间');
        });

        // 后台菜单
        $data = array(
            [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "开发",
                "icon" => "xyicon-coding",
                "path" => "/developer",
                "pmenu" => "/_tab_system",
                "sortnum" => 99,
                "menu_layer" => "admin",
                "menu_type" => 0,
                "route_type" => "",
                "api_prefix" => "",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "一般是开发者采用得到的工具",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "系统",
                "icon" => "xyicon-settings",
                "path" => "/core",
                "pmenu" => "/_tab_system",
                "sortnum" => 1,
                "menu_layer" => "admin",
                "menu_type" => 0,
                "route_type" => "",
                "api_prefix" => "",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "核心系统相关功能",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "清空缓存",
                "icon" => "",
                "path" => "/core/index/cleanRuntime",
                "pmenu" => "/core",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 3,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "清空服务器端缓存",
                "api_method" => "DELETE",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "检查更新",
                "icon" => "",
                "path" => "/core/index/checkUpdate",
                "pmenu" => "/core",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 3,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "检查新版本",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "管理后台",
                "icon" => "",
                "path" => "/_root_admin",
                "pmenu" => "",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => -1,
                "route_type" => "",
                "api_prefix" => "",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "后台根节点",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "系统",
                "icon" => "xyicon-settings",
                "path" => "/_tab_system",
                "pmenu" => "/_root_admin",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => -1,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "系统TAB",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => "",
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "用户",
                "icon" => "xyicon-my-o",
                "path" => "/_tab_user",
                "pmenu" => "/_root_admin",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => -1,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "用户TAB",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => "",
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "内容",
                "icon" => "xyicon-plane-o",
                "path" => "/_tab_content",
                "pmenu" => "/_root_admin",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => -1,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "内容TAB",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => "",
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-core",
                "title" => "财务",
                "icon" => "md-card",
                "path" => "/_tab_money",
                "pmenu" => "/_root_admin",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => -1,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "财务TAB",
                "api_method" => "",
                "is_hide" => 0,
                "doc" => "",
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "菜单列表",
                "icon" => "",
                "path" => "/auth/menu/lists",
                "pmenu" => "/developer",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 3,
                "route_type" => "list",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "管理后台左侧的菜单导航",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "权限管理",
                "icon" => "",
                "path" => "/auth/role/trees",
                "pmenu" => "/core",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 1,
                "route_type" => "list",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "管理系统角色及权限",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "用户列表",
                "icon" => "",
                "path" => "/auth/user/lists",
                "pmenu" => "/core",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 1,
                "route_type" => "list",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "系统注册用户列表",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "修改用户",
                "icon" => "",
                "path" => "/auth/user/edit",
                "pmenu" => "/auth/user/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "修改用户信息",
                "api_method" => "GET|PUT",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "删除用户",
                "icon" => "",
                "path" => "/auth/user/delete",
                "pmenu" => "/auth/user/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "软删除用户",
                "api_method" => "DELETE",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "添加用户",
                "icon" => "",
                "path" => "/auth/user/add",
                "pmenu" => "/auth/user/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "添加用户",
                "api_method" => "GET|POST",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "菜单管理",
                "icon" => "",
                "path" => "/auth/menu/trees",
                "pmenu" => "/developer",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 1,
                "route_type" => "list",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "管理系统后台左侧菜单",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "修改角色",
                "icon" => "",
                "path" => "/auth/role/edit",
                "pmenu" => "/auth/role/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "修改角色信息及权限",
                "api_method" => "GET|PUT",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "删除角色",
                "icon" => "",
                "path" => "/auth/role/delete",
                "pmenu" => "/auth/role/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "删除角色",
                "api_method" => "DELETE",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "添加角色",
                "icon" => "",
                "path" => "/auth/role/add",
                "pmenu" => "/auth/role/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "添加角色",
                "api_method" => "GET|POST",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "角色成员",
                "icon" => "",
                "path" => "/auth/user_role/lists",
                "pmenu" => "/auth/role/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "list",
                "api_prefix" => "v1",
                "api_suffix" => "/:name",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "管理角色成员",
                "api_method" => "GET",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "添加角色成员",
                "icon" => "",
                "path" => "/auth/user_role/add",
                "pmenu" => "/auth/user_role/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "/:name",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "添加一个新角色成员",
                "api_method" => "GET|POST",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "删除角色成员",
                "icon" => "",
                "path" => "/auth/user_role/delete",
                "pmenu" => "/auth/user_role/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "/:uid/:name",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "删除一个角色成员",
                "api_method" => "DELETE",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "添加菜单",
                "icon" => "",
                "path" => "/auth/menu/add",
                "pmenu" => "/auth/menu/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "添加后台菜单(接口)",
                "api_method" => "GET|POST",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "修改菜单",
                "icon" => "",
                "path" => "/auth/menu/edit",
                "pmenu" => "/auth/menu/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "form",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "修改后台菜单(接口)",
                "api_method" => "GET|PUT",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "删除菜单",
                "icon" => "",
                "path" => "/auth/menu/delete",
                "pmenu" => "/auth/menu/trees",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "删除后台菜单(接口)",
                "api_method" => "DELETE",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ],
                [
                "namespace" => "uiadmin",
                "module" => "uiadmin-auth",
                "title" => "用户详情",
                "icon" => "",
                "path" => "/auth/user/info",
                "pmenu" => "/auth/user/lists",
                "sortnum" => 0,
                "menu_layer" => "admin",
                "menu_type" => 2,
                "route_type" => "tab",
                "api_prefix" => "v1",
                "api_suffix" => "/:id",
                "api_params" => "",
                "out_url" => "",
                "is_dev" => 0,
                "create_time" => null,
                "update_time" => null,
                "status" => 1,
                "tip" => "添加用户",
                "api_method" => "GET|POST",
                "is_hide" => 0,
                "doc" => null,
                "api_ext" => "",
                "delete_time" => 0
                ]
        );
        Hyperf\DbConnection\Db::table('xy_auth_menu')->insert($data);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // Schema::dropIfExists('xxx');
    }
}
